package com.wkbb.sports.dto;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;

import java.io.Serializable;
import java.math.BigDecimal;

/**
 * @author 体质分析
 */
@Data
public class PhysicalAnalysisDto implements Serializable {
    //满分4分
    //属性：1力量 2耐力 3协调 4平衡 5灵敏 6速度 7柔韧
    private Double strength;
    private Double endurance;
    private Double coordination;
    private Double balance;
    private Double agility;
    private Double speed;
    private Double flexibility;

    public void format() {
        strength = format(strength);
        endurance = format(endurance);
        coordination = format(coordination);
        balance = format(balance);
        agility = format(agility);
        speed = format(speed);
        flexibility = format(flexibility);
    }

    private Double format(Double num){
        if (num == null) return 2.0;
        BigDecimal bg = new BigDecimal(num);
        return bg.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
    }
}